package com.kim.common.exception;

import com.kim.common.resp.CodeMsg;
import com.kim.common.resp.ResultStatus;

/**
 * 业务异常类
 */
public class BusinessException extends RuntimeException { //运行时异常
    private int errCode;
    private String subErrorMsg;

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(int errCode, String message) {
        super(message);
        this.errCode = errCode;
    }

    public BusinessException(ResultStatus resultEnum) {
        super(resultEnum.getMessage());
        this.errCode = resultEnum.getCode();
        this.subErrorMsg = resultEnum.getMessage();
    }

    public BusinessException(int errCode, String message, String subErrorMsg) {
        super(message);
        this.errCode = errCode;
        this.subErrorMsg = subErrorMsg;
    }

    public BusinessException(CodeMsg codeMsg){
        super(codeMsg.getMsg());
        this.errCode = codeMsg.getCode();
        this.subErrorMsg = codeMsg.getMsg();
    }

    public int getErrCode() {
        return errCode;
    }

    public void setErrCode(int errCode) {
        this.errCode = errCode;
    }

    public String getSubErrorMsg() {
        return subErrorMsg;
    }

    public void setSubErrorMsg(String subErrorMsg) {
        this.subErrorMsg = subErrorMsg;
    }
}
